import 'package:flutter/material.dart';
import 'package:flutter_aggregate/model/common/components/project_item_card.dart';
import 'package:flutter_aggregate/model/onlineOrder/constants.dart';
import 'package:flutter_aggregate/model/plant/constants.dart';
import 'package:flutter_aggregate/router/app_routers.dart';
import 'package:flutter_aggregate/utils/themes.dart';

class CommonPage extends StatelessWidget {
  const CommonPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter 项目集合'),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        child: Wrap(
          alignment: WrapAlignment.start,
          spacing: 16,
          runSpacing: 16,
          children: _projectArr.asMap().keys.map((index) {
            return ProjectItemCard(
              title: _projectArr[index]['title'], 
              icon: _projectArr[index]['icon'], 
              path: _projectArr[index]['path'], 
              theme: _projectArr[index]['theme'] as ThemeData, 
              btnColor: _projectArr[index]['btnColor']
            );
          }).toList()
        ),
      ),
    );
  }

  static final List _projectArr = [
    {
      'title': '种草',
      'icon': 'assets/plant.svg',
      'path': AppRouters.plantHome,
      'theme': Themes.plantTheme,
      'btnColor': palntKPrimaryColor
    },
    {
      'title': '在线点餐',
      'icon': 'assets/onlineOrder.svg',
      'path': AppRouters.onlineHome,
      'theme': Themes.onlineOrderTheme,
      'btnColor': onlineOrderKPrimaryColor
    }
  ];
}